import 'package:get/get.dart';

import '../../../network/HttpGo.dart';
import '../../../services/user_service.dart';

class PmLogic extends GetxController {
  List<Map<String, dynamic>> list = [];

  /// TODO 抢购
  Future<void> toSnapUp(int goodsId) async {
    var header = {'token': UserService.to.token};
    var body = {
      "goodsId": goodsId,
      "password": "123456"
    };
    print(body);
    final res =
        await HttpGo().post('/auctionGoodHash/SnapGoodHash', data: body,headers: header);
    res.ifSuccess((data) {
      if (data is List) {
        list = data.cast<Map<String, dynamic>>();
        update();
      }
    });
    res.ifFailure((e) => e.toast());
  }

  void getList() async {
    var header = {'token': UserService.to.token};
    final res =
        await HttpGo().post("/auctionGoodHash/goodHashList", headers: header);
    res.ifSuccess((data) {
      if (data is List) {
        list = data.cast<Map<String, dynamic>>();
        update();
      }
    });
    res.ifFailure((e) => e.toast());
  }
}
